using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddHttpTrace();

//builder.Services.AddOpenTelemetryTracing(b =>
//{
//    string serviceName = builder.Configuration["Apollo:AppId"];
//    string serviceVersion = "1.0.0";

//    b.AddConsoleExporter()
//    .AddSource(serviceName)
//    .SetResourceBuilder(
//        ResourceBuilder.CreateDefault()
//            .AddService(serviceName: serviceName, serviceVersion: serviceVersion))
//    //.AddHttpClientInstrumentation()
//    .AddAspNetCoreInstrumentation();
//    //.AddSqlClientInstrumentation();
//});

builder.Services.AddHttpClient();

builder.Services.AddKafkaLogger(options => builder.Configuration.GetSection("KafkaLogger").Bind(options));
builder.Services.AddKafkaProducer(options => builder.Configuration.GetSection("KafkaEventBus").Bind(options));

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();


app.UseHttpTrace();

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
